//
//  UIDevice-Extension.swift
//  DHLive
//
//  Created by Mac on 2021/6/27.
//

import Foundation
import UIKit

let kScreenHeight: CGFloat = UIScreen.main.bounds.height
let kScreenWidth: CGFloat = UIScreen.main.bounds.width
let kScreenBounds = UIScreen.main.bounds

let kHeight_Battery_Bar: CGFloat = 20.0

let Height_StatusBar = kHeight_Battery_Bar + kSafeTopHeight
let kHeight_NavBar: CGFloat = 64.0 + kSafeTopHeight
let kHeight_TabBar: CGFloat = 49.0 + kSafeBottomHeight

let kSafeTopHeight: CGFloat = UIDevice.current.isX ? 24.0 : 0
let kSafeBottomHeight: CGFloat = UIDevice.current.isX ? 34.0 : 0

extension UIDevice {
    /// 是否带有刘海，使用计算属性
    /// - Returns: true带刘海safeArea
    fileprivate var isX: Bool {
        let k_isPad = UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad
        let condition = UIScreen.instancesRespond(to: #selector(getter: UIScreen.main.currentMode))
        if condition {
            //判断iPhoneX，Xs 11pro
            let kiPhone_X = __CGSizeEqualToSize(CGSize(width: 1125, height: 2436), UIScreen.main.currentMode!.size) && !k_isPad
            //判断iPhoneXr 11
            let kiPhone_Xr = __CGSizeEqualToSize(CGSize(width: 828, height: 1792), UIScreen.main.currentMode!.size) && !k_isPad
            //判断iPhoneXsMax 11promax
            let kiPhone_Xs_max = __CGSizeEqualToSize(CGSize(width: 1242, height: 2688), UIScreen.main.currentMode!.size) && !k_isPad
            //判断iPhone12 12pro
            let kiPhone12 = __CGSizeEqualToSize(CGSize(width: 1170, height: 2532), UIScreen.main.currentMode!.size) && !k_isPad
            //判断iPhone12promax
            let kiPhone12_pro_max = __CGSizeEqualToSize(CGSize(width: 1284, height: 2778), UIScreen.main.currentMode!.size) && !k_isPad
            //判断iPhone12mini
            let kiPhone12_mini = __CGSizeEqualToSize(CGSize(width: 1080, height: 2340), UIScreen.main.currentMode!.size) && !k_isPad
            
            if kiPhone12_mini || kiPhone12_pro_max || kiPhone12 || kiPhone_Xs_max || kiPhone_Xr || kiPhone_X {
                return true
            }
        }
        
        return false
    }
}
